<?php
$pid = pcntl_fork();
if ($pid<0){
    exit('fork error').PHP_EOL;
}else if ($pid>0){
    pcntl_signal(SIGCHLD,function () use ($pid){
        echo "收到子进程退出".PHP_EOL;
        pcntl_waitpid($pid,$status,WNOHANG);
    });
    cli_set_process_title("php father process");
    while (true){
        sleep(1);
        pcntl_signal_dispatch();
    }
}else if ($pid==0){
    cli_set_process_title("ph child process");
    sleep(20);
    exit;
}